<template>
    <el-form
        :model="resume"
        :rules="resumeRules"
        ref="editFormRef"
        label-width="100px"
    >

        <el-form-item
            label="名字"
            prop="name"
        >
            <el-input v-model="resume.name"/>
        </el-form-item>

        <el-form-item
            label="绑定专业"
            prop="profession"
        >
            <el-select
                v-model="resume.profession"
                filterable
                style="width: 360px"
                placeholder="试试搜索吧~">
                <el-option-group
                    v-for="group in proOptions"
                    :key="group.professionalTypeName"
                    :label="group.professionalTypeName">
                    <el-option
                        v-for="item in group.professions"
                        :key="item.proName"
                        :label="item.proName"
                        :value="item.proId">
                    </el-option>
                </el-option-group>
            </el-select>
        </el-form-item>

        <el-form-item
            label="邮箱"
            prop="email"
        >
            <el-input v-model="resume.email"/>
        </el-form-item>

        <el-form-item
            label="在校排行"
        >
            <el-input v-model="resume.gradesRanking"/>
        </el-form-item>

        <el-form-item
            label="荣誉奖项"
        >
            <el-input type="textarea" v-model="resume.honor"/>
        </el-form-item>

        <el-form-item
            label="项目经历"
        >
            <el-input type="textarea" v-model="resume.projectExperience"/>
        </el-form-item>

        <el-form-item
            label="校园经历"
        >
            <el-input type="textarea" v-model="resume.experienceSchool"/>
        </el-form-item>

        <el-form-item
            label="自我评价"
        >
            <el-input type="textarea" v-model="resume.selfIntroduction"/>
        </el-form-item>

        <el-form-item
            label="实习经历"
        >
            <el-input type="textarea" v-model="resume.internExperience"/>
        </el-form-item>

        <el-form-item>
            <el-button
                type="primary"
                @click="editResume"
            >修改信息</el-button>
        </el-form-item>
    </el-form>

</template>

<script>
	export default {
		name: 'ResumeManage',
        data(){
		    return{
                resume:{
                    resumeId :'',
                    /**
                     * 发送人
                     */
                    fromId:'',
                    /**
                     * 姓名
                     */
                    name:'',
                    /**
                     * 专业
                     */
                    profession:'',
                    email:'',
                    /**
                     * 在校成绩排名
                     */
                    gradesRanking:'',
                    /**
                     * 荣誉奖项
                     */
                    honor:'',
                    /**
                     * 项目经历
                     */
                    projectExperience:'',
                    /**
                     * 校园经历
                     */
                    experienceSchool:'',
                    /**
                     * 技能证书
                     */
                    certificate:'',
                    /**
                     * 自我评价
                     */
                    selfIntroduction:'',
                    /**
                     * 实习经历
                     */
                    internExperience:''
                },
                resumeRules:{
                    name: [
                        {
                            required: true,
                            message: '请输入学生姓名',
                            trigger: 'blur'
                        },
                        {
                            min: 2,
                            max: 15,
                            message: '长度在 2 到 15 个字符',
                            trigger: 'blur'
                        }
                    ],
                    email: [
                        {
                            required: true,
                            message: '请输入学生邮箱',
                            trigger: 'blur'
                        }
                    ],
                    profession: [
                        {
                            required: true,
                            message: '请选择学生专业',
                            trigger: 'blur'
                        }
                    ]
                },
                proOptions:[]
            }
        },
        created () {
		    this.getProfessionDataCascader();
		    this.getResume();
        },
        methods:{
		    getResume(){
		        let self = this;
		        self.utils.sendReq({
                    queryUrl:'/resume/get',
                    req:{
                        method:'get',
                        success:function (req) {
                            if (req.data.code === 200){
                                self.resume = req.data.data;
                            }
                        }
                    }
                })
            },
            editResume(){
		        let self = this;
		        let data = self.resume;
                self.$refs.editFormRef.validate(valid => {
                    if (valid) {
                        self.utils.sendReq({
                            queryUrl:'/resume/update',
                            req:{
                                method:'post',
                                data:data,
                                success:function (req) {
                                    if (req.data.code === 200){
                                        self.$message({
                                            message: req.data.msg,
                                            type: 'success',
                                            showClose: true,
                                            center: true
                                        })
                                        self.getResume();
                                    }
                                }
                            }
                        })
                    }
                })
            },
            getProfessionDataCascader () {
                let self = this
                self.utils.sendReq({
                    queryUrl: 'professionalType/queryAll',
                    req: {
                        method: 'get',
                        success: function (req) {
                            if (req.data.code === 200) {
                                self.proOptions = req.data.data
                            }
                        }
                    }
                })
            }
        }
    }
</script>

<style scoped>

</style>
